//
//  HDNavigationController.m
//  HDecoration
//
//  Created by 曹群 on 15/8/12.
//  Copyright (c) 2015年 HDecoration. All rights reserved.
//

#import "HDNavigationController.h"

@interface HDNavigationController ()

@end

@implementation HDNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSDictionary *attibutes = @{NSFontAttributeName:[UIFont fontWithName:@"STHeitiSC-Light" size:16]};
    self.navigationBar.titleTextAttributes = attibutes;
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [super pushViewController:viewController animated:animated];
    // 添加返回
    if ([self.viewControllers count] > 1)
    {
        if (viewController.navigationItem.leftBarButtonItem == nil)
        {
            GXButton *leftBarBtn = [GXButton buttonWithType:UIButtonTypeCustom];
            leftBarBtn.frame = CGRectMake(0, 0, 40, 40);
            leftBarBtn.imageViewFrame = CGRectMake(0, 10, 12, 20);
            leftBarBtn.relayout = YES;
            [leftBarBtn setImage:[UIImage imageNamed:@"backNavBarBtn"] forState:UIControlStateNormal];
            [leftBarBtn addTarget:self action:@selector(leftBarBtnAction) forControlEvents:UIControlEventTouchUpInside];
            viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBarBtn];
        }
    }
}

- (void)leftBarBtnAction
{
    [self popViewControllerAnimated:YES];
}

@end
